package edu.henu.personnel.service.file;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import edu.henu.personnel.constant.PageHelperConstant;
import edu.henu.personnel.dao.DownloadFileDao;
import edu.henu.personnel.entity.DownLoadFile;
import edu.henu.personnel.vo.NoticeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @program: PersonnelProject
 * @description: 下载文件接口实现类
 * @author: zhuyang
 * @create: 2019-05-25 14:45
 */

@Transactional
@Service
public class FileServiceImpl implements FileService {

    @Autowired
    private DownloadFileDao fileDao;

    @Override
    public PageInfo<DownLoadFile> getFilesByCid(Integer cid, Integer pageNum) {
        PageHelper.startPage(pageNum, PageHelperConstant.displayFileSize);
        List<DownLoadFile> downLoadFileList = fileDao.findDownloadFileByCid(cid);
        PageInfo<DownLoadFile> pageInfo = new PageInfo<>(downLoadFileList);
        return pageInfo;
    }

    @Override
    public int addDownloadFile(DownLoadFile file) {
        return fileDao.insertFile(file);
    }

    @Override
    public int removeDownloadFile(Integer fid) {
        return fileDao.removeFile(fid);
    }
}
